package owl2vowl.model.entities.properties;

import owl2vowl.model.SetWithoutNull;
import owl2vowl.model.entities.AbstractEntity;
import owl2vowl.model.entities.properties.HasCardinality;
import owl2vowl.model.entities.properties.HasInverse;
import owl2vowl.model.visitor.VowlPropertyVisitor;
import java.util.Set;
import org.semanticweb.owlapi.model.IRI;

public abstract class AbstractProperty extends AbstractEntity implements HasInverse, HasCardinality {
	private Set<IRI> domains = new SetWithoutNull();
	private Set<IRI> ranges = new SetWithoutNull();
	private Set<IRI> referencedIris = new SetWithoutNull();
	private IRI mergedDomain;
	private IRI mergedRange;
	private IRI inverse = null;
	private int minCardinality;
	private int maxCardinality;
	private int exactCardinality;

	public IRI getMergedDomain() {
		return this.mergedDomain;
	}

	public void setMergedDomain(IRI mergedDomain) {
		this.mergedDomain = mergedDomain;
	}

	public IRI getMergedRange() {
		return this.mergedRange;
	}

	public void setMergedRange(IRI mergedRange) {
		this.mergedRange = mergedRange;
	}

	protected AbstractProperty(IRI iri, String type) {
		super(iri, type);
	}

	public Set<IRI> getDomains() {
		return this.domains;
	}

	public Set<IRI> getRanges() {
		return this.ranges;
	}

	public void addDomain(IRI iri) {
		this.domains.add(iri);
	}

	public void addRange(IRI iri) {
		this.ranges.add(iri);
	}

	public IRI getJsonDomain() {
		return this.domains.size() == 1 ? (IRI) this.domains.iterator().next() : this.mergedDomain;
	}

	public IRI getJsonRange() {
		return this.ranges.size() == 1 ? (IRI) this.ranges.iterator().next() : this.mergedRange;
	}

	public IRI getInverse() {
		return this.inverse;
	}

	public void addInverse(IRI iri) {
		this.inverse = iri;
	}

	public Integer getExactCardinality() {
		return Integer.valueOf(this.exactCardinality);
	}

	public void setExactCardinality(Integer value) {
		this.exactCardinality = value.intValue();
	}

	public Integer getMaxCardinality() {
		return Integer.valueOf(this.maxCardinality);
	}

	public void setMaxCardinality(Integer value) {
		this.maxCardinality = value.intValue();
	}

	public Integer getMinCardinality() {
		return Integer.valueOf(this.minCardinality);
	}

	public void setMinCardinality(Integer value) {
		this.minCardinality = value.intValue();
	}

	public abstract void accept(VowlPropertyVisitor arg0);

	public Set<IRI> getReferencedIris() {
		return this.referencedIris;
	}

	public void addReferencedProperty(IRI reference) {
		this.referencedIris.add(reference);
	}
}